$dirs = @(
  "D:\alee\exec\development\Revision control\PortableGit\cmd", # PortableGit 使用的就是 cmd 目录
  "D:\msys2\msys64\home\ferder\.sdkman\candidates\maven\current\bin", # maven
  "D:\msys2\msys64\home\ferder\.sdkman\candidates\gradle\current\bin" # gradle
)

$oldUserPath = [Environment]::GetEnvironmentVariable("Path", "User")
$filterDirs = $dirs | ForEach-Object {
  if (-Not $oldUserPath.Contains($_)) {
    "$_" 
  }
}

$newUserPath = [System.String]::Concat($oldUserPath, ";", $filterDirs -join ';')
[Environment]::SetEnvironmentVariable("Path", $newUserPath, "User")

Pause
